package com.example.service;

import com.example.entity.Schools;
import com.example.mapper.SchoolsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class SchoolsService {

    @Resource
    private SchoolsMapper schoolsMapper;

    public void add(Schools schools) {
        schoolsMapper.insert(schools);
    }

    public void deleteById(Integer id) {
        schoolsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Schools schools) {
        schoolsMapper.updateById(schools);
    }

    public Schools selectById(Integer id) {
        return schoolsMapper.selectById(id);
    }

    public List<Schools> selectAll(Schools schools) {
        return schoolsMapper.selectAll(schools);
    }

    public PageInfo<Schools> selectPage(Schools schools, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Schools> schoolsList = schoolsMapper.selectAll(schools);
        return PageInfo.of(schoolsList);
    }
}
